<?php
namespace SisGG\FinalBundle\Entity;

use Symfony\Component\Security\Core\Role\RoleInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use SisGG\FinalBundle\Entity\Usuario;

/**
 * Description of Rol
 *
 * @author martin
 * @ORM\Entity
 */
class Rol implements RoleInterface, \Serializable{
     /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;
    /**
     * @ORM\Column(type="string", length=25, unique=true)
     * @Assert\NotBlank
     */
    private $role;
    /**
     * @ORM\OneToMany(targetEntity="Usuario", mappedBy="role")
     */
    private $users;
    /**
     * @return string
     */
    public function getRole() {
        return $this->role;
    }
    /**
     * @return string
     */
    public function __toString() {
        return $this->role;
    }
    
    /**
     * @return string
     */
    public function serialize()
    {
      return serialize($this->id);
    }

    /**
     * @param string $data
     */
    public function unserialize($data)
    {
      $this->id = unserialize($data);
    }
    
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->users = new \Doctrine\Common\Collections\ArrayCollection();
    }
    


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set role
     *
     * @param string $role
     * @return Rol
     */
    public function setRole($role)
    {
        $this->role = $role;
    
        return $this;
    }

    /**
     * Add users
     *
     * @param SisGG\FinalBundle\Entity\Usuario $users
     * @return Rol
     */
    public function addUser(\SisGG\FinalBundle\Entity\Usuario $users)
    {
        $this->users[] = $users;
    
        return $this;
    }

    /**
     * Remove users
     *
     * @param SisGG\FinalBundle\Entity\Usuario $users
     */
    public function removeUser(\SisGG\FinalBundle\Entity\Usuario $users)
    {
        $this->users->removeElement($users);
    }

    /**
     * Get users
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getUsers()
    {
        return $this->users;
    }
}